<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>12-Vue的生命周期</title>
    <script src="../js/vue.js"></script>
    <script src="../js/jquery-3.6.0.js"></script>

</head>
<body>
<!--1.准备一个div容器-->
<div id="app">
    <p>{{age}}</p>
    <button @click="age++">点我年龄加1</button>
    <button @click="fun1">点我销毁Vue对象</button>
</div>
<script>
    <!--2.准备一个Vue对象和容器绑定-->
    const vm = new Vue({
        // 绑定容器
        el: "#app",
        // 数据
        data: {
            age: 18,
        },
        // 方法
        methods: {
            fun1:function () {
                this.$destroy();
            }
        },
        // 局部过滤器
        filters: {},
        // 监听器
        watch: {},
        beforeCreate:function () {
            console.log(`创建之前age的值${this.age}`);
        },
        created:function () {
            console.log(`创建之后age的值${this.age}`)
        },
        beforeMount:function () {
            console.log(`页面渲染之前的值${$("p").html()}`);
        },
        mounted:function () {
            console.log(`页面渲染之后的值${$("p").html()}`);
        },
        beforeUpdate:function () {
            console.log(`页面改变之前的值${$("p").html()}`);
        },
        updated:function () {
            console.log(`页面改变之后的值${$("p").html()}`);
        },
        beforeDestroy:function () {
            console.log(`Vue销毁之前`)  ;
        },
        destroy:function () {
            console.log(`Vue销毁之后`);
        }
    });
</script>
</body>
</html>